package client

import (
	"virus-proxy/internal/vendor_api/huorong"
)

type Proxy struct {
	ControlCenterIP   string
	ControlCenterPort string
	Vendor            string
	SecretID          string
	SecretKey         string
}

// NewProxy 创建一个新的Proxy实例
func NewProxy(apiURL, token, vendor, secrectId, secrectKey string) *Proxy {
	return &Proxy{
		ControlCenterIP:   apiURL,
		ControlCenterPort: token,
		Vendor:            vendor,
		SecretID:          secrectId,
		SecretKey:         secrectKey,
	}
}

func (p *Proxy) QueryAllGroups() (string, error) {
	return p.NewScanner().QueryAllGroups()
}

func (p *Proxy) ModifyGroupName(groupID, newGroupName string) error {
	return p.NewScanner().ModifyGroupName(groupID, newGroupName)
}

func (p *Proxy) DeleteGroup(groupId string) error {
	return p.NewScanner().DeleteGroup(groupId)
}

func (p *Proxy) QueryTerminals() error {
	return p.NewScanner().QueryTerminals()
}

func (p *Proxy) QueryTerminalDetails(limit, offset int) ([]byte, error) {
	return p.NewScanner().QueryTerminalDetails(limit, offset)
}

func (p *Proxy) CallKillTask(scanList []string, clientIp string) ([]byte, error) {
	return p.NewScanner().CallKillTask(scanList, clientIp)
}

func (p *Proxy) NewScanner() *huorong.HuorongScanner {
	// 现在暂时支持huorong，如果后期有其他杀毒软件厂商接入，在此处接入
	scanner := &huorong.HuorongScanner{ControlCenterIP: p.ControlCenterIP, ControlCenterPort: p.ControlCenterPort, SecretID: p.SecretID, SecretKey: p.SecretKey}
	return scanner
}
